package com.boot.security.server.dao.mffl;

import java.util.List;
import java.util.Map;

import com.boot.security.server.model.mffl.Vo.MfflProfitVo;
import org.apache.ibatis.annotations.*;

import com.boot.security.server.model.mffl.MfflProfit;

@Mapper
public interface MfflProfitDao {

    @Select("select * from mffl_profit t where t.id = #{id}")
    MfflProfit getById(Long id);

    @Delete("delete from mffl_profit where id = #{id}")
    int delete(Long id);

    int update(MfflProfit mfflProfit);
    
    @Options(useGeneratedKeys = true, keyProperty = "id")
    @Insert("insert into mffl_profit(orderId, userId, servciceName, state, money, settlement, createTime, settlementTime, deduction, updateTime) values(#{orderId}, #{userId}, #{servciceName}, #{state}, #{money}, #{settlement}, #{createTime}, #{settlementTime}, #{deduction}, #{updateTime})")
    int save(MfflProfit mfflProfit);
    
    int count(@Param("params") Map<String, Object> params);

    List<MfflProfitVo> list(@Param("params") Map<String, Object> params, @Param("offset") Integer offset, @Param("limit") Integer limit);

    @Select("select * from mffl_profit t where t.orderId = #{orderId} and t.userId = #{userId}")
    MfflProfit getByOrderId(@Param("orderId")Integer orderId,@Param("userId")Integer userId);

    @Select("select * from mffl_profit t where t.orderId = #{orderId}")
    List<MfflProfit> getOrderId(@Param("orderId")Integer orderId);

    @Update("update mffl_profit set settlement = 2 where orderId = #{orderId} ")
    void updateState(@Param("orderId") int id, @Param("settlement") int settlement);
}
